package com.meishij.fragment.malldetailfragment;


import android.os.Bundle;
import android.support.annotation.Nullable;
import android.support.v4.app.Fragment;
import android.support.v4.view.PagerAdapter;
import android.support.v7.widget.GridLayoutManager;
import android.support.v7.widget.RecyclerView;
import android.support.v7.widget.StaggeredGridLayoutManager;
import android.view.LayoutInflater;
import android.view.View;
import android.view.ViewGroup;

import com.meishij.R;
import com.meishij.adapter.MallItemOrderAdapter;
import com.meishij.entry.MallSellEntry;

import java.util.ArrayList;
import java.util.List;

/**
 * A simple {@link Fragment} subclass.
 */
public class MallMessageOrderFragment extends Fragment {

    private View view;
    private RecyclerView shaidan;
    private List<Object> objectList=new ArrayList<>();
    private List<String> stringList=new ArrayList<>();
    private MallItemOrderAdapter mallItemOrderAdapter;

    //这是晒订单的fragment,需要的数据是shaidan,shaidan如果没有就直接是一张图片
    public MallMessageOrderFragment() {
        // Required empty public constructor
    }


    @Override
    public View onCreateView(LayoutInflater inflater, ViewGroup container,
                             Bundle savedInstanceState) {
        // Inflate the layout for this fragment
        if(view!=null){
            return view;
        }
        view = inflater.inflate(R.layout.fragment_mall_message_order, container, false);
        return view;
    }

    @Override
    public void onViewCreated(View view, @Nullable Bundle savedInstanceState) {
        Bundle bundle = getArguments();
        MallSellEntry.ObjBean data = (MallSellEntry.ObjBean) bundle.getSerializable("data");
        shaidan = ((RecyclerView) view.findViewById(R.id.mall_sell_shaidan));
        GridLayoutManager layoutManager = (GridLayoutManager) shaidan.getLayoutManager();
        layoutManager.setSpanCount(1);
        List<MallSellEntry.ObjBean.ShaidanBean> shaidanList = data.getShaidan();
        String logo = data.getStore_infomation().getLogo();
        stringList.add(logo);
        objectList.add(0,shaidanList);//加载recyclerView
        objectList.add(1,null);
        objectList.add(2,stringList);//加载logo
        objectList.add(3,null);//加载"了解商家详情"
        mallItemOrderAdapter = new MallItemOrderAdapter(getContext(),objectList,new int[]{
                R.layout.layout_mall_sell_shaidan_recycler,
                R.layout.layout_mall_sell_item_shaidan_more,
                R.layout.layout_mall_item_bottom_loge,
                R.layout.layout_mall_detail_item_bottom_text
        });
        shaidan.setAdapter(mallItemOrderAdapter);
    }
}
